﻿<!--
	RegExpress
	
	Copyright (c) 2010, Daniel McGaughran
	
	Licensed under the Apache Licence, Version 2.0 (the "Licence");
	you may not use this file except in compliance with the Licence.
	You may obtain a copy of the License at
	
		http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the Licence is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the Licence for the specific language governing permissions and
	limitations under the Licence.
	
	-->

<UserControl x:Class="RegExpress.UI.HostControls.MultiMatch"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:xrCt="clr-namespace:XrControls;assembly=XrControls">

    
    <StackPanel HorizontalAlignment="Center">

        <TextBlock Style="{StaticResource LabelText}" Text="Expression" />
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*" SharedSizeGroup="MMatchInput"/>
				<ColumnDefinition Width="Auto" />
			</Grid.ColumnDefinitions>
        	
			<TextBox Text="{Binding Mode=TwoWay, Path=RegExpression, UpdateSourceTrigger=PropertyChanged}" />
			<Expander Grid.Column="1" Style="{DynamicResource PopupExpander}">
				<Expander.Header>
					<TextBlock Style="{StaticResource ButtonText}" Text="Options" />
				</Expander.Header>
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition />
						<RowDefinition />
						<RowDefinition />
						<RowDefinition />
					</Grid.RowDefinitions>
					
					<xrCt:ToggleSwitch Value="{Binding Path=IsCaseIgnored, Mode=TwoWay}">
						<TextBlock Style="{StaticResource SettingLabel}" Text="IgnoreCase" />
					</xrCt:ToggleSwitch>
					<xrCt:ToggleSwitch Grid.Row="1" Value="{Binding Path=IsWhitespaceIgnored, Mode=TwoWay}">
						<TextBlock Style="{StaticResource SettingLabel}" Text="IgnorePatternWhitespace" />
					</xrCt:ToggleSwitch>
					<xrCt:ToggleSwitch Grid.Row="2" Value="{Binding Path=IsNewlineMatchedByDot, Mode=TwoWay}">
						<TextBlock Style="{StaticResource SettingLabel}" Text="Singleline (Dot matches newline)" />
					</xrCt:ToggleSwitch>
					<xrCt:ToggleSwitch Grid.Row="3" Value="{Binding Path=IsMultiLine, Mode=TwoWay}">
						<TextBlock Style="{StaticResource SettingLabel}" Text="Multiline (^/$ operate per line)" />
					</xrCt:ToggleSwitch>
				</Grid>
			</Expander>
		</Grid>
		<TextBlock Style="{StaticResource LabelText}" Text="Input Cases" />
		<ItemsControl ItemsSource="{Binding Cases}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition SharedSizeGroup="MMatchInput"/>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="MMatchRunCase" />
                            <ColumnDefinition Width="Auto" SharedSizeGroup="MMatchResult" />
                        </Grid.ColumnDefinitions>


                        <TextBox MinWidth="400"
								Text="{Binding Mode=TwoWay, Path=Input, UpdateSourceTrigger=PropertyChanged}" />
                        <Button Grid.Column="1" Command="{Binding Parent.MatchCaseCmd}"
                                CommandParameter="{Binding Index}"
                                HorizontalAlignment="Center" VerticalAlignment="Center">
							<TextBlock Style="{StaticResource ButtonText}" Text="Is Match?" />
						</Button>

                        <xrCt:ToggleSwitch Grid.Column="2" IsReadOnly="True"
                                HorizontalAlignment="Center" VerticalAlignment="Center"
                                IsEnabled="{Binding HasResult}" Value="{Binding IsMatch}">
                        </xrCt:ToggleSwitch>
                    </Grid>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        
        <xrCt:UniformDoubleStack>
            <Button Style="{StaticResource HiddenButton}" Grid.Column="1" Command="{Binding AddCaseCmd}">
				<Path Style="{StaticResource HiddenPath}" Data="M 0,4 L 8,4 M 4,0 L 4,8" />
			</Button>
            
            <Button Style="{StaticResource HiddenButton}" Grid.Column="1" Command="{Binding MatchAllCmd}"
                    xrCt:UniformDoubleStack.IsAtStackEnd="True">
				<Path Style="{StaticResource HiddenPath}" Data="M 7,0 L 1,0 L 5,4 L 1,8 L 7,8" />
			</Button>
        </xrCt:UniformDoubleStack>
        
    </StackPanel>
</UserControl>
